Skip to content
This repository has been archived by the owner on Jun 10, 2018. It is now read-only.

Source maps #528

Closed
wants to merge 60 commits into from
Closed

Conversation

ConradIrwin
Copy link

Merge master into the source map branch (fixes some syntax changes). We could rebase if you guys are au fait with that.

To make this actually useful there are about three parallelizable tasks:

  1. Make sure this branch actually works inside rails (I didn't get it working, but probably user error).
  2. Update the call to Uglify to use compile_with_map
  3. Add compile_with_map to the coffee script gem.

I'm planning to spend a small amount of time working on this, but don't expect anything quickly.

tenderlove and others added 30 commits November 14, 2013 10:41
Current homepage points to an expired domain http://getsprockets.org

This PR updates it to point at the github repo instead.
preventing "undefined method `directory?' for nil:NilClass" when a link
to a non-existent file is present
Correct minor spelling mistakes in README.md
@ConradIrwin
Copy link
Author

This is just an update to #311, nothing new. /cc @josh

@josh
Copy link
Contributor

josh commented Feb 14, 2014

Add compile_with_map to the coffee script gem.

No new calls need to be added there. We can already pass options to compile.

@josh
Copy link
Contributor

josh commented Feb 14, 2014

The one think that is blocking me from progress here is the pipeline processor api. I'm working on redoing it for 3.0 first. Once thats out that will allow processors to pass extra data between each other like source maps.

@ConradIrwin
Copy link
Author

The reason for compile_with_map in uglify was that it needs to return two strings. I guess we could make the method do that if you pass the right options, but it's very odd.

Or we could do it like coffee-rails-source-maps and just write to a temporary file.

@josh
Copy link
Contributor

josh commented Feb 14, 2014

The reason for compile_with_map in uglify was that it needs to return two strings. I guess we could make the method do that if you pass the right options, but it's very odd.

It doesn't really matter, we can invoke whatever api the processor exposes here.

https://github.com/sstephenson/sprockets/blob/master/lib/sprockets/coffee_script_template.rb#L9

There isn't even a unified api right now, so I'm expecting everyone to expose different source map apis. Coffee, Uglifier, Sass, YUI, ClosureCompiler are all going to do different things. Our wrappers will normalize them.

I worked on https://github.com/maccman/sourcemap which is a useful Ruby structure around the json object. Thats what I plan to hand off between processors.

Or we could do it like coffee-rails-source-maps and just write to a temporary file.

Nothing should be written to disk when templates are compiled. It should be a "pure functional" transformation.

@ConradIrwin
Copy link
Author

On Fri, Feb 14, 2014 at 11:30 AM, Joshua Peek [email protected]:

The reason for compile_with_map in uglify was that it needs to return two
strings. I guess we could make the method do that if you pass the right
options, but it's very odd.

It doesn't really matter, we can invoke whatever api the processor exposes
here.

https://github.com/sstephenson/sprockets/blob/master/lib/sprockets/coffee_script_template.rb#L9

Yeah, at the moment that API isn't exposed at all (or at least not
documented at all); so we'll need to fix that gem first.

I worked on https://github.com/maccman/sourcemap which is a useful Ruby

structure around the json object. Thats what I plan to hand off between
processors.

I know, you copied my code from
https://github.com/ConradIrwin/ruby-source_map :). I had a slight about how
uglify will treat the low-fidelity (per-line) source maps we generate; will
it set the column number to 0 for every token on the line, or will it
interpolate correctly; but that's easy to test.

@josh
Copy link
Contributor

josh commented Feb 14, 2014

Yeah, at the moment that API isn't exposed at all (or at least not
documented at all); so we'll need to fix that gem first.

You can just pass whatever options to CoffeeScript.compile.

https://github.com/josh/ruby-coffee-script/blob/master/lib/coffee_script.rb#L47

Though, I'm thinking having a separate compile_with_map would be nice because we could feature detect if the gem supports source maps from sprockets. Backwards compat is a little tricky with that gem because it needs to support every version of coffee-script-source published even when source maps didn't exist.

@ai
Copy link
Contributor

ai commented Feb 23, 2014

Do you need any help with source map support? This task is really important to me.

@MarkMurphy
Copy link

This is taking forever...#311 started 2 years ago...ugh. Really want to see this finally land.

@ai
Copy link
Contributor

ai commented Apr 22, 2014

Grunt already has source map support. Even Mincer (Sprockets port to node.js). So I think this feature is very important, because source map helps with Sass and CoffeeScript debug.

@jeltz
Copy link
Contributor

jeltz commented Apr 23, 2014

I too offer to help on source maps if you need it.

@agius
Copy link

agius commented May 28, 2014

+1 - happy to review / test / etc.

@josh josh closed this Jun 27, 2014
Repository owner locked and limited conversation to collaborators Jun 27, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.